function _defineProperty(e, t, n) {
    return t in e ? Object.defineProperty(e, t, {
        value: n,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = n, e;
}

var MAX_CUSTOM = 10;

Component({
    externalClasses: [ "custom-bar", "custom-box" ],
    properties: {
        name: String,
        title: {
            type: String,
            value: "自定义标签"
        },
        option: Array,
        selected: {
            type: Number,
            value: -1,
            observer: function(e) {
                this.setData({
                    selected: e
                });
            }
        },
        custom: Boolean,
        showDeleteCustom: Boolean,
        showAddCustom: {
            type: Boolean,
            value: !1
        },
        setting: Boolean,
        loose: Boolean,
        checkbox: Boolean,
        canCancel: Boolean
    },
    methods: {
        _select: function(e) {
            var t = e.currentTarget.dataset.id, n = this.data, a = n.canCancel, o = n.checkbox, i = n.name, r = n.selected;
            if (o) return this._selectMore(t);
            a && r === t && (t = 0), this.setData({
                selected: t
            }), this.triggerEvent("select", _defineProperty({}, i, t));
        },
        _selectMore: function(t) {
            var e = this.data.option;
            e.forEach(function(e) {
                e.id === t && (e.selected = !e.selected);
            }), this.triggerEvent("selectmore", {
                option: e
            });
        },
        _add: function() {
            this.selectComponent("#addLabel").show();
        },
        _delete: function(e) {
            var t = e.currentTarget.dataset, n = t.id, a = t.index;
            this.triggerEvent("delete", {
                id: n,
                index: a
            });
        },
        onAddConfirm: function(e) {
            var t = e.detail.value;
            t.length > MAX_CUSTOM ? wx.showModal({
                content: "最大不能超过".concat(MAX_CUSTOM, "个字"),
                showCancel: !1
            }) : this.triggerEvent("add", {
                value: t
            });
        },
        hideModal: function() {
            this.selectComponent("#addLabel").hide();
        },
        resetSelect: function() {
            var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : 0;
            this.setData({
                selected: e
            });
        },
        setting: function() {
            this.triggerEvent("set");
            var e = getApp().globalData, t = e.contact.contact, n = e.card;
            this.$route("/pages/radar/nichedetail/setlabel/setlabel?setting=1&guid=".concat(t.guid, "&cardid=").concat(n.cardid));
        }
    }
});